using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace JumpyCat.bamboo
{
    class ButtonMenu
    {
        int index;

        Rect showRect;

        Texture2D buttonImage;

        private int ITEM_BUTTON_MENU_WITH = 248;
        private int ITEM_BUTTON_MENU_HEIGHT = 68;
        private int PADDING_VERTICAL_BUTTON = 30;

        public ButtonMenu(int buttonIndex, String filePath)
        {

            buttonImage = Game1.sharedContent.Load<Texture2D>(filePath);
            index = buttonIndex;

            int startPosY = 250;
            int startPosX = (GameEngine.SCREEN_WIDTH - ITEM_BUTTON_MENU_WITH) / 2;
            int realDrawY = startPosY
                    + (index * (PADDING_VERTICAL_BUTTON + ITEM_BUTTON_MENU_HEIGHT));

            showRect = new Rect(startPosX, realDrawY, ITEM_BUTTON_MENU_WITH,
                    ITEM_BUTTON_MENU_HEIGHT);
        }

        public ButtonMenu(String filePath)
        {

            buttonImage = Game1.sharedContent.Load<Texture2D>(filePath);

            int startPosY = 10;
            int startPosX = 15;
            showRect = new Rect(startPosX, startPosY, buttonImage.Width * 2, buttonImage.Height * 2);
        }

        public ButtonMenu(String filePath, int x , int y, int width, int height)
        {

            buttonImage = Game1.sharedContent.Load<Texture2D>(filePath);

            int startPosY = x;
            int startPosX = y;
            showRect = new Rect(startPosX, startPosY, width, height);
        }



        public ButtonMenu(String filePath, int y)
        {

            buttonImage = buttonImage = Game1.sharedContent.Load<Texture2D>(filePath);

            int startPosY = y;
            int startPosX = (GameEngine.SCREEN_WIDTH - buttonImage.Width * 2) / 2; ;
            showRect = new Rect(startPosX, startPosY, buttonImage.Width * 2, buttonImage.Height * 2);
        }

        public ButtonMenu(String filePath, int x, int y)
        {

            buttonImage = buttonImage = Game1.sharedContent.Load<Texture2D>(filePath);

            int startPosY = y;
            int startPosX = x;
            showRect = new Rect(startPosX, startPosY, buttonImage.Width * 2,buttonImage.Height * 2);
        }



        public void render(SpriteBatch g)
        {
            g.Draw(buttonImage, new Rectangle(this.showRect.x, this.showRect.y, buttonImage.Width * 2, buttonImage.Height * 2), Color.White);

        }


        public void renderByRect(SpriteBatch g)
        {
            g.Draw(buttonImage, new Rectangle(this.showRect.x, this.showRect.y, this.showRect.width, this.showRect.height), Color.White);

        }


        public bool isTouchInsideButton(int x, int y)
        {

            return (showRect.isPointInRect(x, y));
        }
    }
}
